package com.mind.adjust.service.impl;

import com.mind.adjust.mapper.AjAttachCateRulesetMapper;
import com.mind.system.domain.AjAttachCateRuleset;
import com.mind.adjust.service.AjAttachCateRulesetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 规则集(AjAttachCateRuleset)表服务实现类
 *
 * @author makejava
 * @since 2024-07-15 15:52:03
 */
@Service("attachCateRulesetService")
public class AjAttachCateRulesetServiceImpl implements AjAttachCateRulesetService {
    @Autowired
    private AjAttachCateRulesetMapper attachCateRulesetMapper;

    /**
     * 查询规则集信息集合
     * 
     * @param attachCateRuleset 规则集信息
     * @return 规则集信息集合
     */
    @Override
    public List<AjAttachCateRuleset> selectAttachCateRulesetList(AjAttachCateRuleset attachCateRuleset)
    {
        return attachCateRulesetMapper.selectAttachCateRulesetList(attachCateRuleset);
    }

    /**
     * 通过规则集ID查询规则集信息
     * 
     * @param attachCateRulesetId 规则集ID
     * @return 角色对象信息
     */
    @Override
    public AjAttachCateRuleset selectAttachCateRulesetById(Long attachCateRulesetId)
    {
        return attachCateRulesetMapper.selectAttachCateRulesetById(attachCateRulesetId);
    }

    /**
     * 删除规则集信息
     * 
     * @param attachCateRulesetId 规则集ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateRulesetById(Long attachCateRulesetId)
    {
        return attachCateRulesetMapper.deleteAttachCateRulesetById(attachCateRulesetId);
    }

    /**
     * 批量删除规则集信息
     * 
     * @param attachCateRulesetIds 需要删除的规则集ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateRulesetByIds(Long[] attachCateRulesetIds)
    {
        return attachCateRulesetMapper.deleteAttachCateRulesetByIds(attachCateRulesetIds);
    }

    /**
     * 新增保存规则集信息
     * 
     * @param attachCateRuleset 规则集信息
     * @return 结果
     */
    @Override
    public int insertAttachCateRuleset(AjAttachCateRuleset attachCateRuleset)
    {
        return attachCateRulesetMapper.insertAttachCateRuleset(attachCateRuleset);
    }

    /**
     * 修改保存规则集信息
     * 
     * @param attachCateRuleset 规则集信息
     * @return 结果
     */
    @Override
    public int updateAttachCateRuleset(AjAttachCateRuleset attachCateRuleset)
    {
        return attachCateRulesetMapper.updateAttachCateRuleset(attachCateRuleset);
    }
    
    /**
     * 批量插入
     *
     * @param attachCateRulesetList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjAttachCateRuleset> attachCateRulesetList) {
        int size = 0;
        for(AjAttachCateRuleset attachCateRuleset: attachCateRulesetList) {
            if (attachCateRulesetMapper.selectAttachCateRulesetByName(attachCateRuleset.getName()) == null){
                attachCateRulesetMapper.insertAttachCateRuleset(attachCateRuleset);
                size ++;
            }
        }
        return size;
    }
}
